﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;

namespace WeBlog.Attributes
{
    public class EmailRegexAttribute : RegularExpressionAttribute
    {
        private const string EmailPattern = @"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$";
        public EmailRegexAttribute() : base(EmailPattern )
        {
            ErrorMessageResourceType = typeof (Resources.Strings);
            ErrorMessageResourceName = "Validation_InvalidEmail";
        }
    }
    
    public class UrlRegexAttribute : RegularExpressionAttribute
    {
        private const string UrlPattern =
            @"^(ht|f)tp(s?)\:\/\/[0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*(:(0-9)*)*(\/?)([a-zA-Z0-9\-\.\?\,\'\/\\\+&amp;%\$#_]*)?$";

        public UrlRegexAttribute() : base( UrlPattern )
        {
            ErrorMessageResourceType = typeof(Resources.Strings);
            ErrorMessageResourceName = "Validation_InvalidUrl";
        }
    }

    public class WeBlogRequiredAttribute : RequiredAttribute
    {
        public WeBlogRequiredAttribute()            
        {
            ErrorMessageResourceType = typeof (Resources.Strings);
            ErrorMessageResourceName = "Required";
        }
    }
}
